#!/bin/bash

# Readme:
# 1. Search "menu=", replace "(Beijing Nanjing Shanghai)" with your own options 
# 2. Add your own logic fuction(e.g: doX) like "do1" function below and call your "doX" at "# ..." below
	
menu=(A7008_AIMEI A7008_SANYI A7008_XST A7008_HONGXIANG Q8 Q11 cj7102-3 cj8101 N713 N914 M11 Q11-V17 Q8-WCB Q8-1024 Q11-V17S A6502_AIMEI)

function print_menu()
{
    local i=1
    local choice
    for choice in "${menu[@]}"
    do
        echo "     $i. $choice"
        i=$(($i+1))
    done

    echo
}

print_menu

function chooseAndGo()
{
    local answer

    echo -n "please select product: "
    read answer

    local selection=

    if [ -z "$answer" ]
    then
    	answer=1
    elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$")
    then
        if [ $answer -le ${#menu[@]} ]
        then
            selection=${menu[$(($answer-1))]}
        else
            echo "Invalid option: $answer"
            return
        fi
    else
        echo "Invalid option: $answer"
        return
    fi

    echo "You have current product: $selection"  
    bash $DEVICE/CompileConfig/select_board_super.sh $selection
}

chooseAndGo
